﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

using WAF.DAO;
using StrategyTest.Common;
using StrategyTest.Strategy;

namespace StrategyTest
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }

        private void Form1_Load(object sender, EventArgs e)
        {
            WAF.DAO.DbAccess.SetDefaultDbType(DbAccess.DatabaseType.SQLITE, "Data Source=./SR.db");

            Test1 test = new Test1();
            DayBars dayBars = new DayBars(test);
            
            DateTime start = DateTime.Now;

            IDataReader iReader = DbAccess.ExeReader("select * from ContinuousData");

            Bar bar = new Bar();
            
            //读取行情数据
            while (iReader.Read())
            {
                bar.OpenTime = DateTime.Parse(iReader.GetString(0));

                bar.Open    = iReader.GetDouble(1);
                bar.High    = iReader.GetDouble(2);
                bar.Low     = iReader.GetDouble(3);
                bar.Close   = iReader.GetDouble(4);
                
                dayBars.Quote(bar);
            }

            iReader.Close();

            DateTime end = DateTime.Now;

            this.Text = (end - start).TotalMilliseconds.ToString();

            this.textBox1.Text = test.money.ToString() + "|win:" + test.win.ToString() + "|loss:" + test.loss.ToString();
        }
    }
}
